package com.chcplayer.ui
{
import com.chcplayer.ChcPlayerApp;
import com.chcplayer.enums.FormCloseType;

import flash.events.Event;

/**
 * author yh
 */
public class ChooseBgColorWindow extends BaseWindow
{
	/**
	 */
	public static const BUTTON_Y:int = 527;
	/**
	 */
	public static const CHOOSER_X:int = 50;
	/**
	 */
	public static const CHOOSER_Y:int = 100;
	/**
	 */
	public static const COMPARE_Y:int = 50;
//--------------------------------------------------------------------------------------------------
// private
//--------------------------------------------------------------------------------------------------
	/**
	 */
	protected var p_obChooser:HsbColorChooser = new HsbColorChooser();
	/**
	 */
	protected var p_obCompare:ColorCompare = new ColorCompare();
	/**
	 */
	public function ChooseBgColorWindow()
	{
		super("选择背景色", 500, 602);
		this._init();
	}
//--------------------------------------------------------------------------------------------------
// private
//--------------------------------------------------------------------------------------------------
	private function _init():void
	{
		p_obChooser.x = CHOOSER_X;
		p_obChooser.y = CHOOSER_Y;
		/*
		*/
		p_obCompare.x = CHOOSER_X;
		p_obCompare.y = COMPARE_Y;
		this.addChild(p_obCompare);
		this.addChild(p_obChooser);
		/*
		*/
		p_btnDefault.x = CHOOSER_X;
		p_btnDefault.y = 10;
		p_btnCancel.y = p_btnOK.y = BUTTON_Y;
		/*
		*/
		this.addChild(p_btnDefault);
		this.addChild(p_btnCancel);
		this.addChild(p_btnOK);
		p_obChooser.addEventListener(Event.CHANGE, change_chooser);
	}
//==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
// protected
//==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
	/**
	 */
	override protected function _OnShow():void
	{
		p_obChooser.setColor(p_obApp.getBgColor());
		p_obApp.setTempBgColoring(true);
	}
	/**
	 */
	override protected function _ToDefault():void
	{
		p_obChooser.setColor(p_obApp.getDefaultBgColor());
		p_obApp.setTempBgColor(p_obChooser.getColor());
	}
	/**
	 */
	override protected function _OnClose():void
	{
		p_obApp.setTempBgColoring( false );
		if ( FormCloseType.CONFIRM == p_strCloseFlag )
		{
			p_obApp.setBgColor(p_obChooser.getColor());
		}
	}
	/**
	 */
	protected function _OnChange():void
	{
		p_obApp.setTempBgColor( p_obChooser.getColor() );
		p_obCompare.setNewColor( p_obChooser.getColor() );
	}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// events
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	/**
	 */
	private function change_chooser(e:Event):void
	{
		this._OnChange();
	}
	/**
	 */
}
}